<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">

<head>
    <th:block th:include="include :: header('新增市纪委监委信访移送件办理情况登记')" />
</head>

<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-templatetable5-add">
            <input id="progressId" name="workProgress.progressId" th:value="${workProgress.progressId}" type="hidden">
            <input id="status" name="workProgress.status" th:value="${workProgress.status}" type="hidden">
            <h4 class="form-header h4">市纪委监委信访移送件办理情况登记</h4>
            <div class="row">
                <div class="col-sm-12">
                    <button type="button" class="btn btn-white btn-sm" onclick="addColumn()"><i class="fa fa-plus">
                            增加</i></button>
                    <button type="button" class="btn btn-white btn-sm" onclick="delColumn()"><i class="fa fa-minus">
                            删除</i></button>
                    <div class="col-sm-12 select-table table-bordered">
                        <table id="bootstrap-table"></table>
                    </div>
                    <div class="row">
                        <div class="col-sm-4">
                            <div class="form-group">
                                <label class="col-sm-4 control-label">填报单位：</label>
                                <div class="form-control-static" th:text="${workProgress.receiveDept}"></div>
                            </div>
                        </div>
                        <div class="col-sm-4">
                            <div class="form-group">
                                <label class="col-sm-4 control-label">填报人：</label>
                                <div class="form-control-static" th:text="${workProgress.receiveUser}"></div>
                            </div>
                        </div>
                        <div class="col-sm-4">
                            <div class="form-group">
                                <label class="col-sm-4 control-label">填报时间：</label>
                                <div class="form-control-static" th:text="${today}"></div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
        <div class="row">
            <div class="col-sm-offset-5 col-sm-10">
                <button type="button" class="btn btn-sm btn-success" onclick="submitHandler('3')"><i
                        class="fa fa-plus"></i>保 存</button>&nbsp;
                <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler('4')"><i
                        class="fa fa-check"></i>上 报</button>&nbsp;
                <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i
                        class="fa fa-reply-all"></i>关 闭</button>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:src="@{/js/jquery.tmpl.js}"></script>
    <script th:inline="javascript">
        var prefix = ctx + "work/templatetable5";

        $(function () {
            var options = {
                url: prefix + "/list",
                queryParams: {progressId: $('#progressId').val()},
                pagination: false,
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                sidePagination: "client",
                columns: [
                    [{
                        field: 'index',
                        checkbox: true,
                        rowspan: 2,
                        align: 'center',
                        valign: 'middle'
                    }, {
                        field: 'val1',
                        title: '序号',
                        align: 'center',
                        valign: 'middle',
                        rowspan: 2,
                        formatter: function (value, row, index) {
                            var columnIndex = $.common.sprintf("<input class='form-control' type='hidden' name='workTemplateTable5List[%s].val1' value='%s'>", index, $.table.serialNumber(index));
                            return columnIndex + $.table.serialNumber(index);
                        }
                    }, {
                        field: 'val2',
                        title: '信访编号',
                        align: 'center',
                        valign: 'middle',
                        rowspan: 2,
                        formatter: function (value, row, index) {
							var html = $.common.sprintf("<input class='form-control' type='text' name='workTemplateTable5List[%s].val2' value='%s' >", index, value);
							return html;
						}
                    }, {
                        title: '反映人信息',
                        align: 'center',
                        colspan: 2
                    }, {
                        title: '被反映人信息',
                        align: 'center',
                        colspan: 3
                    }, {
                        field: 'val8',
                        title: '问题摘要',
                        align: 'center',
                        valign: 'middle',
                        rowspan: 2,
                        formatter: function (value, row, index) {
                            var html = $.common.sprintf("<input class='form-control' type='text' name='workTemplateTable5List[%s].val8' value='%s'>", index, value);
                            return html;
                        }
                    }, {
                        field: 'val9',
                        title: '承办单位收件时间',
                        align: 'center',
                        valign: 'middle',
                        rowspan: 2,
                        formatter: function (value, row, index) {
							var html = $.common.sprintf("<input class='form-control' type='text' name='workTemplateTable5List[%s].val9' value='%s'>", index, value);
							return html;
						}
                    }, {
                        field: 'val10',
                        title: '办结日期',
                        align: 'center',
                        valign: 'middle',
                        rowspan: 2,
                        formatter: function (value, row, index) {
							var html = $.common.sprintf("<input class='form-control' type='text' name='workTemplateTable5List[%s].val10' value='%s'>", index, value);
							return html;
						}
                    }, {
                        field: 'val11',
                        title: '处置方式',
                        align: 'center',
                        valign: 'middle',
                        rowspan: 2,
                        formatter: function (value, row, index) {
                            var html = $.common.sprintf("<input class='form-control' type='text' name='workTemplateTable5List[%s].val11' value='%s'>", index, value);
                            return html;
                        }
                    }, {
                        field: 'val12',
                        title: '属实程度',
                        align: 'center',
                        valign: 'middle',
                        rowspan: 2,
                        formatter: function (value, row, index) {
                            var html = $.common.sprintf("<input class='form-control' type='text' name='workTemplateTable5List[%s].val12' value='%s'>", index, value);
                            return html;
                        }
                    }, {
                        field: 'val13',
                        title: '处理情况',
                        align: 'center',
                        valign: 'middle',
                        rowspan: 2,
                        formatter: function (value, row, index) {
                            var html = $.common.sprintf("<input class='form-control' type='text' name='workTemplateTable5List[%s].val13' value='%s'>", index, value);
                            return html;
                        }
                    }, {
                        title: '了结批示情况 ',
                        align: 'center',
                        colspan: 3
                    }, {
                        field: 'val17',
                        title: '调查组成员',
                        align: 'center',
                        valign: 'middle',
                        rowspan: 2,
                        formatter: function (value, row, index) {
                            var html = $.common.sprintf("<input class='form-control' type='text' name='workTemplateTable5List[%s].val17' value='%s'>", index, value);
                            return html;
                        }
                    }, {
                        field: 'val18',
                        title: '是否为实名举报',
                        align: 'center',
                        valign: 'middle',
                        rowspan: 2,
                        formatter: function (value, row, index) {
                            var data = [{ index: index, type: value }];
		                    return $("#selectRealName").tmpl(data).html();
                        }
                    }, {
                        title: '实名举报反馈情况',
                        align: 'center',
                        colspan: 4
                    }, {
                        field: 'val23',
                        title: '备注',
                        align: 'center',
                        valign: 'middle',
                        rowspan: 2,
                        formatter: function (value, row, index) {
                            var html = $.common.sprintf("<input class='form-control' type='text' name='workTemplateTable5List[%s].val23' value='%s'>", index, value);
                            return html;
                        }
                    }],
                    [{
                        field: 'val3',
                        align: 'center',
                        title: '姓名',
                        formatter: function (value, row, index) {
                            var html = $.common.sprintf("<input class='form-control' type='text' name='workTemplateTable5List[%s].val3' value='%s' >", index, value);
                            return html;
                        }
                    }, {
                        field: 'val4',
                        align: 'center',
                        title: '单位及联系方式',
                        formatter: function (value, row, index) {
                            var html = $.common.sprintf("<input class='form-control' type='text' name='workTemplateTable5List[%s].val4' value='%s' >", index, value);
                            return html;
                        }
                    }, {
                        field: 'val5',
                        align: 'center',
                        title: '姓名',
                        formatter: function (value, row, index) {
                            var html = $.common.sprintf("<input class='form-control' type='text' name='workTemplateTable5List[%s].val5' value='%s' >", index, value);
                            return html;
                        }
                    }, {
                        field: 'val6',
                        align: 'center',
                        title: '单位及职务',
                        formatter: function (value, row, index) {
                            var html = $.common.sprintf("<input class='form-control' type='text' name='workTemplateTable5List[%s].val6' value='%s' >", index, value);
                            return html;
                        }
                    }, {
                        field: 'val7',
                        align: 'center',
                        title: '职级',
                        formatter: function (value, row, index) {
                            var html = $.common.sprintf("<input class='form-control' type='text' name='workTemplateTable5List[%s].val7' value='%s'>", index, value);
                            return html;
                        }
                    }, {
                        field: 'val14',
                        align: 'center',
                        title: '批示领导',
                        formatter: function (value, row, index) {
                            var html = $.common.sprintf("<input class='form-control' type='text' name='workTemplateTable5List[%s].val14' value='%s'>", index, value);
                            return html;
                        }
                    }, {
                        field: 'val15',
                        align: 'center',
                        title: '批示时间',
                        formatter: function (value, row, index) {
							var html = $.common.sprintf("<input class='form-control' type='text' name='workTemplateTable5List[%s].val15' value='%s'>", index, value);
							return html;
						}
                    }, {
                        field: 'val16',
                        align: 'center',
                        title: '批示内容',
                        formatter: function (value, row, index) {
                            var html = $.common.sprintf("<input class='form-control' type='text' name='workTemplateTable5List[%s].val16' value='%s'>", index, value);
                            return html;
                        }
                    }, {
                        field: 'val19',
                        align: 'center',
                        title: '反馈时间',
                        formatter: function (value, row, index) {
							var html = $.common.sprintf("<input class='form-control' type='text' name='workTemplateTable5List[%s].val19' value='%s'>", index, value);
							return html;
						}
                    }, {
                        field: 'val20',
                        align: 'center',
                        title: '反馈方式',
                        formatter: function (value, row, index) {
                            var html = $.common.sprintf("<input class='form-control' type='text' name='workTemplateTable5List[%s].val20' value='%s'>", index, value);
                            return html;
                        }
                    }, {
                        field: 'val21',
                        align: 'center',
                        title: '反映人意见',
                        formatter: function (value, row, index) {
                            var html = $.common.sprintf("<input class='form-control' type='text' name='workTemplateTable5List[%s].val21' value='%s'>", index, value);
                            return html;
                        }
                    }, {
                        field: 'val22',
                        align: 'center',
                        title: '经办人员',
                        formatter: function (value, row, index) {
                            var html = $.common.sprintf("<input class='form-control' type='text' name='workTemplateTable5List[%s].val22' value='%s'>", index, value);
                            return html;
                        }
                    }]
                ]
            };
            $.table.init(options);
        });

        /* 主子表-提交 */
      /*  function submitHandler(index, layero) {
            var data = $("#form-templatetable5-add").serializeArray();
            $.operate.save(prefix + "/add", data);
        }*/
        function submitHandler(status) {
            if ($.validate.form()) {
                var data = $("#form-templatetable5-add").serializeArray()
                $('#status').val(status)
                console.log("data:" + JSON.stringify(data));
                console.log("status" + status);
                $.operate.save(prefix + "/add", $("#form-templatetable5-add").serializeArray());
            }
        }


        function editColumn() {
            var dataColumns = [
                { checkbox: false},
                {field: 'val1',title: '序号',align: 'center',valign: 'middle'}, 
                {field: 'val2',title: '序号',align: 'center',valign: 'middle'}, 
                {field: 'val3',title: '序号',align: 'center',valign: 'middle'}, 
                {field: 'val4',title: '序号',align: 'center',valign: 'middle'}, 
                {field: 'val5',title: '序号',align: 'center',valign: 'middle'}, 
                {field: 'val6',title: '序号',align: 'center',valign: 'middle'}, 
                {field: 'val7',title: '序号',align: 'center',valign: 'middle'}, 
                {field: 'val8',title: '序号',align: 'center',valign: 'middle'}, 
                {field: 'val9',title: '序号',align: 'center',valign: 'middle'}, 
                {field: 'val10',title: '序号',align: 'center',valign: 'middle'}, 
                {field: 'val11',title: '序号',align: 'center',valign: 'middle'}, 
                {field: 'val12',title: '序号',align: 'center',valign: 'middle'}, 
                {field: 'val13',title: '序号',align: 'center',valign: 'middle'}, 
                {field: 'val14',title: '序号',align: 'center',valign: 'middle'}, 
                {field: 'val15',title: '序号',align: 'center',valign: 'middle'}, 
                {field: 'val16',title: '序号',align: 'center',valign: 'middle'}, 
                {field: 'val17',title: '序号',align: 'center',valign: 'middle'}, 
                {field: 'val18',title: '序号',align: 'center',valign: 'middle'}, 
                {field: 'val19',title: '序号',align: 'center',valign: 'middle'}, 
                {field: 'val20',title: '序号',align: 'center',valign: 'middle'}, 
                {field: 'val21',title: '序号',align: 'center',valign: 'middle'}, 
                {field: 'val22',title: '序号',align: 'center',valign: 'middle'}, 
                {field: 'val23',title: '序号',align: 'center',valign: 'middle'}, 
                ]
            var params = new Array();
            var data = $("#" + table.options.id).bootstrapTable('getData');
            var count = data.length;
            for (var dataIndex = 0; dataIndex < count; dataIndex++) {
                var columns = $('#' + table.options.id + ' tr[data-index="' + dataIndex + '"] td');
                var obj = new Object();
                for (var i = 0; i < columns.length; i++) {
                    var inputValue = $(columns[i]).find('input');
                    var selectValue = $(columns[i]).find('select');
                    var key = dataColumns[i].field;
                    if ($.common.isNotEmpty(inputValue.val())) {
                        obj[key] = inputValue.val();
                    } else if ($.common.isNotEmpty(selectValue.val())) {
                        obj[key] = selectValue.val();
                    } else {
                        obj[key] = "";
                    }
                }
                var item = data[dataIndex];
                var extendObj = $.extend({}, item, obj);
                params.push({ index: dataIndex, row: extendObj });
            }
            $("#" + table.options.id).bootstrapTable("updateRow", params);
        }
        function delColumn(column) {
            editColumn();
            var subColumn = $.common.isEmpty(column) ? "index" : column;
            var ids = $.table.selectColumns(subColumn);
            if (ids.length == 0) {
                $.modal.alertWarning("请至少选择一条记录");
                return;
            }
            $("#" + table.options.id).bootstrapTable('remove', { field: subColumn, values: ids });
        }
        function addColumn() {
            var count = $("#" + table.options.id).bootstrapTable('getData').length;
            editColumn();
            $("#" + table.options.id).bootstrapTable('insertRow', {
                index: count,
                row: {
                    index: false,
                    val1: "",
                    val2: "",
                    val3: "",
                    val4: "",
                    val5: "",
                    val6: "",
                    val7: "",
                    val8: "",
                    val9: "",
                    val10: "",
                    val11: "",
                    val12: "",
                    val13: "",
                    val14: "",
                    val15: "",
                    val16: "",
                    val17: "",
                    val18: "",
                    val19: "",
                    val20: "",
                    val21: "",
                    val22: "",
                    val23: "",
                }
            });
        }

        $("#bootstrap-table").on("post-body.bs.table", function (e, args) {
			$("input[name$='val9']").datetimepicker({
				format: "yyyy/mm/dd",
				minView: "month",
				autoclose: true,
				pickerPosition: 'top-right'
			});
		});

        $("#bootstrap-table").on("post-body.bs.table", function (e, args) {
			$("input[name$='val10']").datetimepicker({
				format: "yyyy/mm/dd",
				minView: "month",
				autoclose: true,
				pickerPosition: 'top-right'
			});
		});

        $("#bootstrap-table").on("post-body.bs.table", function (e, args) {
			$("input[name$='val15']").datetimepicker({
				format: "yyyy/mm/dd",
				minView: "month",
				autoclose: true,
				pickerPosition: 'top-right'
			});
		});

        $("#bootstrap-table").on("post-body.bs.table", function (e, args) {
			$("input[name$='val19']").datetimepicker({
				format: "yyyy/mm/dd",
				minView: "month",
				autoclose: true,
				pickerPosition: 'top-right'
			});
		});
    </script>
</body>

</html>

<!-- 实名选举 -->
<script id="selectRealName" type="text/x-jquery-tmpl">
    <div>
        <select class='form-control' name='workTemplateTable5List[${index}].val18'>
            <option value=""></option>
            <option value="0" {{if type==="0"}}selected{{/if}}>是</option>
            <option value="1" {{if type==="1"}}selected{{/if}}>否</option>
        </select>
    </div>
</script>
